using System.Collections;

namespace Slaks.Graphs.Wordnet
{
	public class WordnetVertex : Vertex
	{
		private IList m_synonymBundle;
		private bool m_isDirty; //some boolean flag
		private long m_directSynonymId;

		public WordnetVertex(long id) : base(id)
		{
			m_synonymBundle = new ArrayList();
			m_isDirty = false;
		}

		public WordnetVertex(long id, double frequency) : base(id, frequency)
		{
			m_synonymBundle = new ArrayList();
		}

		public bool IsDirty
		{
			get { return m_isDirty; }
			set { m_isDirty = value; }
		}

		public bool IsSynonymExists(long id)
		{
			foreach (Synonym syn in this.GetSynonymBundle())
			{
				foreach (long synId in syn.GetSynonymList())
				{
					if (synId == id) return true;
				}
			}
			return false;
		}

		public bool IsSynonymExistsUntilSpecificLevel(long id, int synonymBetweenCategory, int synonymWithinCategory)
		{
			int synBetweenCategory = 0;
			int synWithinCategory = 0;

			foreach (Synonym syn in this.GetSynonymBundle())
			{
				synonymWithinCategory = 0;
				foreach (long synId in syn.GetSynonymList())
				{
					if (synId == id) return true;
					++synWithinCategory;
					if (synWithinCategory == synonymWithinCategory) break;
				}
				++synBetweenCategory;
				if (synBetweenCategory == synonymBetweenCategory) break;
			}
			return false;
		}

		/// <summary>
		/// get the synonyms as Synonym
		/// </summary>
		/// <returns></returns>
		public IList GetSynonymBundle()
		{
			return m_synonymBundle;
		}

		/// <summary>
		/// Used when the node id is node found in other graph but one node from another graph
		/// has synonym id equal to this node id. so we can assign direct synonym id to the that
		/// id node , such that we will know about the relation
		/// </summary>
		public long DirectSynonymId
		{
			get { return m_directSynonymId; }
			set { m_directSynonymId = value; }
		}

	}
}